package dict

import (
	"gin/tai"
	tccommon "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	nlp "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/nlp/v20190408"
)

func Find(v string) (*nlp.DescribeDictResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewDescribeDictRequest()
	request.DictId = tccommon.StringPtr(v)
	response, err := client.DescribeDict(request)
	return response, err
}

func Create(v *string, d *string) (*nlp.CreateDictResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewCreateDictRequest()
	request.Name = v
	request.Description = d
	return client.CreateDict(request)
}

func Delete(v string) (*nlp.DeleteDictResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewDeleteDictRequest()
	request.DictId = tccommon.StringPtr(v)
	return client.DeleteDict(request)
}

func Update(v *string, name *string, description *string) (*nlp.UpdateDictResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewUpdateDictRequest()
	request.DictId = v
	request.Name = name
	request.Description = description
	return client.UpdateDict(request)
}

func Select(limit *uint64, offset *uint64) (*nlp.DescribeDictsResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewDescribeDictsRequest()
	request.Limit = limit
	request.Offset = offset
	return client.DescribeDicts(request)
}

func LexicalAnalysis(dictId string, text string) (*nlp.LexicalAnalysisResponse, error) {
	client, _ := tai.GetNlpClient()
	request := nlp.NewLexicalAnalysisRequest()
	request.DictId = tccommon.StringPtr(dictId)
	request.Text = tccommon.StringPtr(text)
	return client.LexicalAnalysis(request)
}
